package com.jt.tenant.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.jt.tenant.R;
import com.jt.tenant.app.JTApplication;
import com.jt.tenant.conn.GetDiagnosticCar;

import java.util.List;

/**
 * Created by Administrator on 2016/3/14.
 */
public class DetectionAdapter extends BaseAdapter {

    private LayoutInflater layoutInflater;

    private Context context;

    private List<GetDiagnosticCar.Detection> mList;

    private boolean hasDct = false;

    public DetectionAdapter(Context context, List<GetDiagnosticCar.Detection> mList) {

        this.context = context;

        this.mList = mList;

        layoutInflater = ((Activity) context).getLayoutInflater();

    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;

        if (convertView == null) {

            convertView = JTApplication.ScaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_detection, null));

            convertView.setTag(viewHolder = new ViewHolder());

            viewHolder.detection_text = (TextView) convertView.findViewById(R.id.detection_text);

        } else {

            viewHolder = (ViewHolder) convertView.getTag();

        }

//        if(hasDct){
//            if(!mList.get(position).isType){
//                viewHolder.detection_text.setText(mList.get(position).description);
//
//            }
//
//        }else{
            viewHolder.detection_text.setText((position+1)+".  "+mList.get(position).description);

//        }


        return convertView;

    }

    private class ViewHolder {

        public TextView detection_text;

    }

}
